package com.sykj.bsc.rwl.exection;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

public class MyExceptionResolver implements HandlerExceptionResolver{

	public ModelAndView resolveException(HttpServletRequest req, HttpServletResponse resp, Object hander,
			Exception e) {
		MyExcetion myException=null;	
		
		if(e instanceof MyExcetion) {
			myException=(MyExcetion) e;
		}else {
			myException=new MyExcetion("未知异常,请和管理员联系");
		}
		String message=myException.getMessage();
		ModelAndView mv=new ModelAndView();
		mv.addObject("message", message);
		mv.setViewName("error");
		return mv;
	}

}
